home *** CD-ROM | disk | FTP | other *** search
/ United Public Domain Gold 2 / United Public Domain Gold 2.iso / business / pb016.dms / pb016.adf / Config!S < prev    next >
Text File  |  1992-06-18  |  12KB  |  461 lines

  1. -----------------------------------------------------------------------------
  2. |                              Config!S                                        |
  3. |         Copyright (C) 1986-92 Rick Stiles.  All rights reserved.            |
  4. -----------------------------------------------------------------------------
  5.  
  6. *************************************
  7. N-variables used:
  8. n0-n13  scratch numbers
  9.  
  10. Buffers used:
  11. buf51-54    scratch buffers
  12. buf37    copied columnar text
  13. buf38    directory names
  14. buf41    swap buf
  15. buf45    UNDO buffer
  16. buf46    invert buf
  17. buf47    hilite buf
  18. buf48    replace text
  19. buf49    search string
  20.  
  21. *************************************
  22.  
  23. <defines:
  24. define(N_0 ,n0)
  25. define(N_1 ,n1)
  26. define(N_2 ,n2)
  27. define(N_3 ,n3)
  28. define(N_4 ,n4)
  29. define(N_5 ,n5)
  30. define(N_6 ,n6)
  31. define(N_7 ,n7)
  32. define(N_8 ,n8)
  33. define(N_9 ,n9)
  34. define(N_10 ,n10)
  35. define(N_11 ,n11)
  36. define(N_12 ,n12)
  37. define(N_13 ,n13)
  38. define(B_1 ,buf51)
  39. define(B_2 ,buf52)
  40. define(B_3 ,buf53)
  41. define(B_4 ,buf54)
  42. define(COLUMNAR_BUF ,buf37)
  43. define(DIR_NAMES ,buf38)
  44. define(SWAP_BUF ,buf41)
  45. define(UNDO_BUF ,buf45)
  46. define(INVERT_BUF ,buf46)
  47. define(HILITE_BUF ,buf47)
  48. define(REPLACE_TXT ,buf48)
  49. define(SEARCH_STR ,buf49)
  50.  
  51. define(Eat_MouseUp_Input ,624)
  52. >
  53.  
  54.  
  55. ======== SPELLING CMDS ======
  56.  
  57. Start spell-checking mode by loading in the dictionary table.
  58. <rAmiga-u:  if (spellerUp)
  59.                 putMsg("Speller is up")
  60.             else if (startSpell("Udtable","Udict",1))
  61.                 putMsg("Speller is up")
  62.             else if (startSpell("s:Udtable","s:Udict",1)) .. K. Perano
  63.                  putMsg("Speller is up")
  64.             else if (startSpell("u:Udtable","u:Udict",1)) .. K. Perano
  65.                 putMsg("Speller is up")
  66.             else {
  67.                 putMsg("No memory or dictionary not found")
  68.                 returnFalse
  69.             } >
  70.  
  71. Find first misspelled word, starting at cursor.  Abort with Amiga-ESC.
  72. <rAmiga-c:
  73.     if (not spellerUp) {
  74.         putMsg("Speller not up")
  75.         returnFalse
  76.     }
  77.     putMsg("")
  78.     while (not spell(B_4,curFile,SWAP_BUF)) runKey(virtual-z) >
  79.  
  80. Click word in msg line (B_4), select word to replace word before cursor.
  81. <virtual-z:
  82.     if (isEmpty(B_4)) return
  83.     insertRgn(B_4,efile," ***",all)
  84.     putMsg(B_4)
  85.     vscroll(atCursor)
  86.     updateDisplay
  87.     getKeyVal(N_9,N_6)
  88.     if (eqNum(N_9,normal-esc)) abort
  89.     mousexy(N_7,N_8)
  90.     runKey(Eat_MouseUp_Input)                      .. soak mouseUp
  91.     if (geNum(N_9,normal-gadget1) & geNum(normal-gadget4,N_9)
  92.                                  & gtNum(N_8,10) & gtNum(20,N_8)) {
  93.         div(N_7,N_7,8)
  94.         incNum(N_7)
  95.         moveCursor(B_4,sfile)
  96.         moveCursor(B_4,eword)
  97.         locToIndex(B_4,N_4,atcursor)
  98.         if (gtNum(N_7,N_4)) {
  99.             indexToLoc(B_4,atCursor,N_7)
  100.             if (is(B_4,alpha)) {
  101.                 movecursor(B_4,eword)
  102.                 movecursor(B_4,sword)
  103.                 movecursor(curfile,sword)
  104.                 if (is(curfile,upperCase)) toUpper(B_4)
  105.                 clearRgn(curfile,word)
  106.                 insertrgn(curfile,atcursor,B_4,word)
  107.                 updateDisplay
  108.             }
  109.         }
  110.     }
  111.     putMsg("")
  112.     freeBuf(B_4)
  113.     runKey(Eat_MouseUp_Input)                      .. soak mouseUp
  114. >
  115.  
  116. Spell-check from cursor fwd.  Mark bad words with "@".
  117. <rAmiga-m:
  118.     if (not runKey(rAmiga-u)) returnFalse
  119.     putMsg("Spell checking ... abort with Amiga-ESC")
  120.     while (not spell(" ",curFile,SWAP_BUF)) insertChar(curFile,"@") >
  121.  
  122. Force file saving to finish so buffer is unlocked
  123. <104:
  124.     push(N_9,N_9)
  125.     push(N_9,N_8)
  126.     while (getStackSize(N_9,N_9,N_8) & gtNum(N_8,0)) delay(5)
  127.     pop(N_9,N_8)
  128.     pop(N_9,N_9)
  129. >
  130.  
  131. Load supplemental dictionary & spell from cursor fwd.  Add to supplement.
  132. <rAmiga-l:
  133.     if (not runKey(rAmiga-u)) returnFalse
  134.     equateNum(N_4,curFile)
  135.     putMsg("Dict supplement to use (pmESC = UdSupplement)")
  136.     freebuf(B_4)
  137.     equateNum(N_10,0)
  138.     if (inputString(B_4))  {
  139.        if (not loadFile(B_4)) goto label(3)
  140.     } else {
  141. label(3)
  142.         if (not loadFile("UdSupplement")) {
  143.             if (not newFile) {
  144.                 putMsg("Close a file for me!")
  145.                 returnFalse
  146.             }
  147.             setFileName(curfile,"UdSupplement")
  148.         }
  149.     }
  150.     putMsg("Spell checking ... abort with Amiga-ESC")
  151.     if (getFlag(curFile,searchCaps)) flipFlag(curFile,searchCaps)
  152. label(0)
  153.     while (not spell(" ",buf[N_4],curFile)) {
  154.         moveCursor(buf[N_4],sWord)
  155.         freeBuf(B_4)
  156.         insertRgn(B_4,eFile,buf[N_4],word)
  157.         moveCursor(buf[N_4],eWord)
  158.         moveCursor(B_4,sFile)
  159.         if (not is(B_4,"'") & not is(B_4,alpha)) goto label(0)
  160.         moveCursor(B_4,eFile)
  161.         putMsg(B_4)                               .. remove for faster speed
  162.  
  163.         ..  this sect for speed
  164.         moveCursor(B_4,sFile)
  165.         copyChar(B_4,N_11)                          .. copy 1st char of word
  166.         freeBuf(B_2)
  167.         insertChar(B_2,eLine)                      .. load in eline-1stchar
  168.         insertChar(B_2,N_11)
  169.         moveCursor(curFile,eFile)                 .. search for starting place
  170.         setSearch(B_2)
  171.         search(curfile,locA,locB,-1)
  172.         moveCursor(curFile,eWord)                  .. move fwd, so sWord works
  173.         if (is(curFile,sFile)) goto label(1)
  174.         while (nothing) {
  175.             moveCursor(curFile,sWord)
  176.             freeBuf(B_3)
  177.             insertRgn(B_3,eFile,curFile,word)
  178.             stringComp(N_3,B_4,B_3,1)                       .. ignore case
  179.             if (eqNum(N_3,0)) goto label(0)             .. found it, continue
  180.             if (gtNum(N_3,0)) {
  181.  label(1)
  182.                 moveCursor(curFile,eWord)
  183.                 moveCursor(curFile,eChar)
  184.  label(2)
  185.                 insertRgn(curFile,atCursor,B_4,all)
  186.                 insertChar(curFile,eLine)
  187.                 updateDisplay                       .. remove for faster speed
  188.                 incNum(N_10)
  189.                 if (gtNum(N_10,19)) {
  190.                     fileSize(curFile,N_10)              .. force buffer packing
  191.                     equateNum(N_10,0)
  192.                 }
  193.                 goto label(0)
  194.             }
  195.             if (is(curFile,sFile)) goto label(2)
  196.         }
  197.     }
  198.     moveCursor(curFile,sFile)
  199.     putMsg("These words weren't in dictionary")
  200.     .. stopSpell                               .. use if want speller removed
  201.     >
  202.  
  203. Merge dict supplement with dict-files.  dict.A-Z must be in Current Directory.
  204. <rAmiga-d:
  205.     if (isEmpty(curFile)) returnFalse
  206.     moveCursor(curFile,sFile)
  207.     freeBuf(B_2)
  208.     freeBuf(B_4)
  209.     insertRgn(B_4,eFile,"S:dict. ",all)
  210.     if (getFlag(curFile,searchCaps)) flipFlag(curFile,searchCaps)
  211.     equateNum(N_0,0)
  212.     while (nothing) {
  213.         moveCursor(curFile,eWord)
  214.         moveCursor(curFile,sWord)
  215.         freeBuf(B_3)
  216.         if (not insertRgn(B_3,eFile,curFile,word)) {
  217. label(6)    if (getFlag(B_2,changed)) saveFile(B_2)
  218.             runKey(104)                             .. force save to complete
  219.             goto label(0)
  220.         }
  221.         moveCursor(B_3,sFile)
  222.         toUpper(B_3)
  223.         copyChar(B_3,N_4)                    .. copy 1st letter of word A-Z
  224.         toLower(B_3)
  225.         if (eqNum(N_4,39)) equateNum(N_4,65)             .. apost becomes 'A'
  226.         else {
  227.             if (gtNum(N_4,90)) goto label(1)                   .. must be A-Z
  228.             if (gtNum(65,N_4)) goto label(1)
  229.         }
  230.         moveCursor(B_4,eFile)
  231.         moveCursor(B_4,sChar)
  232.         swapChar(B_4,N_4)                          .. make it "dict.A" etc.
  233.  
  234.         if (not eqNum(N_4,N_0)) {
  235.             if (not eqNum(N_0,0)
  236.                 & getFlag(B_2,changed)) saveFile(B_2)
  237.             runKey(104)                             .. force save to complete
  238.             clearRgn(B_2,all)
  239.             fileSize(B_2,N_12)                        .. make it pack buffer
  240.             if (not insertFile(B_2,eFile,B_4)) {
  241.                 putMsg("Can't find dict.A-Z!")
  242.                 returnFalse
  243.             }
  244.             setFileName(B_2,B_4)
  245.             if (getFlag(B_2,changed)) flipFlag(B_2,changed)
  246.             equateNum(N_0,N_4)                            .. save dict-letter
  247.         }
  248.         .. put word in dict.
  249.         moveCursor(B_3,eFile)
  250.         putMsg(B_3)
  251.         insertChar(B_3,eLine)
  252.         moveCursor(B_2,eFile)
  253. label(2)
  254.         setSearch(B_3)
  255.         if (search(B_2,locA,locB,-1)) {
  256.             if (is(B_2,sWord)) goto label(1)
  257.             goto label(2)                                .. continue searching
  258.         }
  259.         .. didn't find it.  Do the slow scan & insert the word.
  260.         moveCursor(B_3,eFile)
  261.         moveCursor(B_3,sChar)
  262.         clearChar(B_3)                                      .. remove eLine
  263.         moveCursor(B_2,eFile)
  264.         equateNum(N_12,1)
  265. label(4)
  266.         while (nothing) {
  267.             if (eqNum(N_12,1)) do(N_13,1,40) moveCursor(B_2,sWord)
  268.             moveCursor(B_2,sWord)
  269.             freeBuf(B_1)
  270.             insertRgn(B_1,eFile,B_2,word)
  271.             stringComp(N_3,B_3,B_1,1)                       .. ignore case
  272.             if (eqNum(N_3,0)) goto label(1)             .. found it, continue
  273.             if (gtNum(N_3,0)) {
  274.                 if (eqNum(N_12,1)) goto label(5)
  275.                 moveCursor(B_2,eWord)
  276.                 moveCursor(B_2,eChar)
  277. label(3)
  278.                 insertRgn(B_2,atCursor,B_3,all)
  279.                 insertChar(B_2,eLine)
  280.                 goto label(1)
  281.             }
  282.             if (is(B_2,sFile)) {
  283.                 if (eqNum(N_12,1)) {
  284. label(5)
  285.                     equateNum(N_12,0)
  286.                     do (N_13,1,41) moveCursor(B_2,eWord)
  287.                     goto label(4)
  288.                 }
  289.                 goto label(3)
  290.             }
  291.         }
  292.  
  293. label(1) .. next word
  294.         moveCursor(curFile,eLine)
  295.         moveCursor(curFile,eChar)
  296.         updateDisplay
  297.         if (is(curFile,eFile)) goto label(6)
  298.     }
  299. label(0)
  300.     putMsg("Done.  Run Udbuild to rebuild working dict & table")
  301.     freeBuf(B_2)
  302. >
  303.  
  304. Remove words from dict-files.  dict.A-Z must be in Current Directory.
  305. <rAmiga-e:
  306.     if (isEmpty(curFile)) returnFalse
  307.     moveCursor(curFile,sFile)
  308.     freeBuf(B_2)
  309.     freeBuf(B_4)
  310.     insertRgn(B_4,eFile,"S:dict. ",all)
  311.     if (getFlag(curFile,searchCaps)) flipFlag(curFile,searchCaps)
  312.     equateNum(N_0,0)
  313.     while (nothing) {
  314.         moveCursor(curFile,eWord)
  315.         moveCursor(curFile,sWord)
  316.         freeBuf(B_3)
  317.         if (not insertRgn(B_3,eFile,curFile,word)) {
  318. label(6)
  319.                 if (getFlag(B_2,changed)) saveFile(B_2)
  320.                 runKey(104)                         .. force save to complete
  321.                 goto label(0)
  322.         }
  323.         moveCursor(B_3,sFile)
  324.         toUpper(B_3)
  325.         copyChar(B_3,N_4)                    .. copy 1st letter of word A-Z
  326.         toLower(B_3)
  327.         if (eqNum(N_4,"'")) equateNum(N_4,"A")           .. apost becomes 'A'
  328.         else {
  329.             if (gtNum(N_4,"Z")) goto label(1)                   .. must be A-Z
  330.             if (gtNum(65,N_4)) goto label(1)
  331.         }
  332.         moveCursor(B_4,eFile)
  333.         moveCursor(B_4,sChar)
  334.         swapChar(B_4,N_4)                          .. make it "dict.A" etc.
  335.  
  336.         if (not eqNum(N_4,N_0)) {
  337.             if (not eqNum(N_0,0) & getFlag(B_2,changed)) saveFile(B_2)
  338.             runKey(104)                             .. force save to complete
  339.             clearRgn(B_2,all)
  340.             fileSize(B_2,N_12)                        .. make it pack buffer
  341.             if (not insertFile(B_2,eFile,B_4)) {
  342.                 putMsg("Can't find dict.A-Z!")
  343.                 returnFalse
  344.             }
  345.             setFileName(B_2,B_4)
  346.             if (getFlag(B_2,changed)) flipFlag(B_2,changed)
  347.             equateNum(N_0,N_4)                            .. save dict-letter
  348.         }
  349.         .. remove word from dict.
  350.         moveCursor(B_3,eFile)
  351.         putMsg(B_3)
  352.         insertChar(B_3,eLine)
  353.         moveCursor(B_2,eFile)
  354. label(2)
  355.         setSearch(B_3)
  356.         if (search(B_2,locA,locB,-1)) {
  357.             if (is(B_2,sWord)) {
  358.                 clearRgn(B_2,loc)
  359.                 goto label(1)                                     .. next word
  360.             }
  361.             goto label(2)                                .. continue searching
  362.         }
  363.  
  364. label(1) .. next word
  365.         moveCursor(curFile,eLine)
  366.         moveCursor(curFile,eChar)
  367.         if (is(curFile,eFile)) goto label(6)
  368.         updateDisplay
  369.     }
  370. label(0)
  371.     putMsg("Done.  Run Udbuild to rebuild working dict & table")
  372.     freeBuf(B_2)
  373. >
  374.  
  375. Stop spell-checking mode.  (Frees up about 12k of memory.)
  376. <rAmiga-f: if (spellerUp) { stopSpell putMsg("Speller removed") } >
  377.  
  378. ========== Split Windows =========
  379.  
  380. Remove current split window
  381. <lAmiga-0: splitWindow(curFile,0)>
  382.  
  383. Split window to show current file
  384. <lAmiga-c: splitWindow(curFile,splitSize)>
  385.  
  386. Split window to show Undo buffer
  387. <lAmiga-1: splitWindow(UNDO_BUF,splitSize)>
  388.  
  389. Split window to show search buffer
  390. <lAmiga-2: splitWindow(SEARCH_STR,splitSize)>
  391.  
  392. Split window to show replace buffer
  393. <lAmiga-3: splitWindow(REPLACE_TXT,splitSize)>
  394.  
  395. Split window to show copied-hilite buffer
  396. <lAmiga-4: splitWindow(HILITE_BUF,splitSize)>
  397.  
  398. Split window to show copied-invert buffer
  399. <lAmiga-5: splitWindow(INVERT_BUF,splitSize)>
  400.  
  401. Split window to show copied-columnar buffer
  402. <lAmiga-6: splitWindow(COLUMNAR_BUF,splitSize)>
  403.  
  404. Split window to show directory names
  405. <lAmiga-7: splitWindow(DIR_NAMES,splitSize) >
  406.  
  407. Set split window size
  408. <lAmiga-8:
  409.     putMsg("# lines in split window (2 or more):")
  410.     if (inputNum(N_4) & geNum(N_4,2)) equateNum(splitSize,N_4)
  411.     putMsg("")>
  412.  
  413. Switch to next window split
  414. <lAmiga-9: toggle(windowSplit)>
  415.  
  416. Adjust active split window size with mouse
  417. <lAmiga-=:
  418.     getSplitLines(N_3,N_2)                           .. see if is upper split
  419.     if (eqNum(N_3,0)) {
  420.         putMsg("Adjust lower splits, not top one")
  421.         returnFalse                                 .. don't size main window
  422.     }
  423.     putMsg("Press button, move mouse to set split window size")
  424.     getkey(N_4)
  425.     if (!mouseDown) return
  426.     mouseXY(N_6,N_5)                      .. N_5 = starting mouseY
  427.     equateNum(N_4,curFile)              .. N_4 = curfile buf#
  428.     equateNum(N_1,0)
  429.  
  430. label(0)
  431.         if (inputWaiting) goto label(1)
  432.         trackMouse
  433.         mouseXY(N_8,N_9)                      .. N_9 = current mouseY
  434.         getSplitLines(N_3,N_2)              .. get start & stop
  435.         sub(N_2,N_2,N_3)                    .. N_2 = # lines in curfile split
  436.         if (gtNum(N_5,N_9)) {                 .. if starting mouseY>current mouseY
  437.             if (gtNum(N_3,3)) incNum(N_2)    .. if startline>3 inc #lines in split
  438.             else goto label(0)              .. else goto top of loop
  439.         }
  440.         else if (gtNum(N_9,N_5)) decNum(N_2)  .. if cur mouseY > start mouseY
  441.                                             .. decrement #lines in split
  442.         else goto label(0)                  .. if mouseY unchanged goto top
  443.         if (!eqNum(N_5,N_9)) {                .. if start mouseY != cur mouseY
  444.             splitWindow(curFile,0)          .. TERMINATE current split
  445.             if (gtNum(2,N_2)) equateNum(N_2,2) .. min lines = 2
  446.             splitWindow(buf[N_4],N_2)        .. reopen split
  447.             if (eqNum(N_1,0)) { fullRefresh incNum(N_1) }
  448.             updateDisplay
  449.             equateNum(N_5,N_9)                .. start mouseY = cur mouseY
  450.         }
  451.     goto label(0)
  452.  
  453.     .. return point
  454. label(1)
  455.     editBuf(buf[N_4])
  456.     putmsg("")
  457.     >
  458.  
  459.  
  460. <defines: >
  461.